$(document).ready(function(){
	$("#username").focus();
});

function userAdd() {

	var inputpassword = $("#inputPassword1").val();
	var inputpassword2 = $("#inputPassword2").val();
	
		
		if($("input[type='checkbox']").is(':checked')){
			$("#enable").val(1);
		}else{
			$("#enable").val(0);	
		}
		$.ajax({
	        cache: false,
	        type: "POST",
	        url:"/platform/windows/user/save",
	        data:$('#userAddForm').serialize(),
	        async: false,
	        success: function(data) {
	            if(data.message=="ok")
	            {
	            	window.location.href=getWebRootPath()+"/windows/user.html";
	            }
	            else
	            {
	            	$("#inputPassword1").val("");
	            	$("#inputPassword2").val("");
	            	if(data.usernameMsg!=null){
	            		$('#username').attr("placeholder",data.usernameMsg);
	            		$('#inputUsername').attr("class","fg-line has-error");
	            		$('#erroricon').show();
	            	}
	            	if(data.passwordMsg!=null){
	            		$("#inputPassword1").attr("placeholder",data.passwordMsg);
	            		
	            	}else if(data.passwordMsg2!=null){
	            		$("#inputPassword2").attr("placeholder",data.passwordMsg2);
	            		
	            	}else if(data.passwordmach!=null){
	            		$("#inputPassword1").attr("placeholder",data.passwordmach);
	            		$("#inputPassword2").attr("placeholder",data.passwordmach);
	            		
	            	}
	            
	            	
	            }
	        }
	    });

	
	
	
}

function goBack()
{
	window.location.href=getWebRootPath()+"/windows/user.html";
}